package models

import (
	"time"

	"github.com/shopspring/decimal" // You need to run: go get github.com/shopspring/decimal
	"gorm.io/gorm"
)

// TradeRecord 网格交易记录
// @gorm table:trade_records
type TradeRecord struct {
	gorm.Model

	ConfigID    int             `gorm:"not null;index;comment:配置ID"`//暂时设置为空
	LevelID     *int            `gorm:"index;comment:关联网格层级"`//暂时设置为空
	TradeTime   time.Time       `gorm:"type:datetime(3);not null;comment:交易时间"`
	ActionType  int             `gorm:"not null;comment:交易类型"` // 1-buy 2-sell 3-fee 4-adjust 5-deposit 6-withdraw
	Price       decimal.Decimal `gorm:"type:decimal(18,8);comment:成交价格"`
	Quantity    decimal.Decimal `gorm:"type:decimal(18,8);not null;comment:交易数量"`
	Amount      decimal.Decimal `gorm:"type:decimal(18,8);not null;comment:交易金额"`
	Fee         decimal.Decimal `gorm:"type:decimal(18,8);default:0;comment:手续费"`
	FeeCurrency string          `gorm:"size:10;comment:手续费币种"`
	USDTBalance decimal.Decimal `gorm:"type:decimal(18,8);not null;comment:USDT余额"`
	CoinBalance decimal.Decimal `gorm:"type:decimal(18,8);not null;comment:币余额"`
	OrderID     string          `gorm:"size:50;comment:交易所订单ID"`
	Comment     string          `gorm:"size:255;comment:备注信息"`
}

// TableName 自定义表名
func (TradeRecord) TableName() string {
	return "trade_records"
}
